package leader.print;

import java.util.List;

import leader.service.DirectTeacherService;
import leader.tool.JTableDefine;
import teacher.bean.Teacher;
import teacher.bean.Treatise;
import tools.StringDate;

public class TreatisePrint {
	public void printTreatise(List<Treatise> lists) {
		System.out.println(lists.size());
		DirectTeacherService DT = new DirectTeacherService();
		String[][] columnNames = new String[lists.size()+1][7];
		
		columnNames[0] = new String[]{"编号","名称","作者","通讯作者","出版日期","出版社","概念"};
		for(int i=1;i<=lists.size();i++) {
			Treatise treatise = lists.get(i-1);
			columnNames[i][0] = String.valueOf(i);
			columnNames[i][1] = treatise.getName();
			columnNames[i][2] = treatise.getAuthor();
			Teacher tea = new Teacher();
			tea.setTeaId(treatise.getTeaId());			
			columnNames[i][3] = DT.selectTeacherById(tea).getName();
			StringDate date = new StringDate();
			columnNames[i][4] = date.DateToString(treatise.getDate());
			columnNames[i][5] = treatise.getPress();
			columnNames[i][6] = treatise.getAbstract_();
		}
		int[] px = new int[]{40,120,50,50,80,80,105};
		JTableDefine d = new JTableDefine();
		d.printTable(columnNames,px);
		System.out.println("============================");
	}
}
